<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>角色管理</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<link href="${ctx }/css/style.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" src="${ctx }/js/jquery/jquery-1.6.1.min.js"></script>
		<script type="text/javascript">
			$(function() {
				$("#lnkAddRole").click(function() {
					if(window.showModalDialog("${ctx}/role/toAddRole.action","","status=no;dialogWidth=550px;dialogHeight=500px;menu=no;resizeable=yes;scroll=yes;center=yes;edge=raise") == "OK") {
						document.location.href="${ctx}/role/listRoles.action";				
					}
				});

				$("#lnkBrowseRoleRight").click(function() {
					window.open("${ctx}/role/browsRoleRight.action");
				});

				$("#lnkDiscount").click(function() {
					if(window.showModalDialog("${ctx}/role/toModifyDiscount.action","","status=no;dialogWidth=550px;dialogHeight=500px;menu=no;resizeable=yes;scroll=yes;center=yes;edge=raise") == "OK") {
						document.location.href="${ctx}/role/listRoles.action";
					}
				});
			});

			modifyRole = function(id) {
				if(window.showModalDialog("${ctx}/role/toModifyRole.action?id=" + id,"","status=no;dialogWidth=550px;dialogHeight=500px;menu=no;resizeable=yes;scroll=yes;center=yes;edge=raise") == "OK") {
					document.location.href="${ctx}/role/listRoles.action";			  
				}
			}

			removeRole = function(id) {
				if (confirm("确认要删除么？")) {
					var url = "${ctx}/role/removeRole.action?id=" + id;

					location.href = url;
				}
			}
		</script>
	</head>
	<body>
		<div>
			<div style="width: 99%; height: 30px; text-align: left;">
				当前位置：角色管理
			</div>
			<div
				style="float: left; width: 40%; background-color: #EDDEA0; height: 30px;">
				<b>用户角色管理</b>
			</div>
			<div style="float: right; width: 59%; background-color: #EDDEA0; height: 30px;">
				<a href="#" id="lnkAddRole"> <img alt="" src="${ctx }/images/Add.gif"
						style="text-align: justify; border: 0" />&nbsp;<u>添加角色</u> </a>
				&nbsp;&nbsp;&nbsp;
				<a href="#" id="lnkBrowseRoleRight"> 
					<img alt="" src="${ctx }/images/scan.gif" style="text-align: justify; border: 0" />&nbsp;<u>功能浏览</u> </a>
				&nbsp;&nbsp;&nbsp;
				<a href="#" id="lnkDiscount"> 
					<img alt="" src="${ctx }/images/write.gif" style="text-align: justify; border: 0" />&nbsp;<u>会员优惠价</u> </a>
			</div>

			<div style="width: 100%; background-color: #FBF7E6">
				<div>
					<table cellspacing="2" cellpadding="3" rules="all" border="1" style="background-color: #DEBA84; border-color: #DEBA84; border-width: 1px; border-style: None; width: 100%;">
						<thead>
							<tr style="color: White; background-color: #A55129; font-weight: bold; font-size: 11px;">
								<th>角色ID</th>
								<th>角色名称</th>
								<th>角色描述</th>
								<th>优惠价比</th>
								<th>操作</th>
								<th>分配角色权限</th>
							</tr>
						</thead>
						<tbody>
							<s:if test="roles.size() == 0">
								<tr style="color: #000066; background-color: #FFF7E7; font-size: 13px; text-align: center;">
									<td colspan="6">
										暂无数据显示！
									</td>
								</tr>
							</s:if>
							<s:else>
								<s:iterator value="roles">
									<tr style="color: #000066; background-color: #FFF7E7; font-size: 13px;">
										<td>
											<s:property value="id" />
										</td>
										<td>
											<s:property value="roleName" />
										</td>
										<td>
											<s:property value="roleDesc" />
										</td>
										<td>
											<s:if test="null == discount">
												&nbsp;
											</s:if>
											<s:else>
												<s:property value="discount" />
											</s:else>
										</td>
										<td>
											<span>
												<a href="#" onclick="modifyRole('<s:property value="id" />');">
													<font color="blue">修改</font>
												</a>
												|
												<a href="#" onclick="removeRole('<s:property value="id" />');">
													<font color="blue">删除</font>
												</a>
											</span>
										</td>
										<td>
											<span>
												<a href='${ctx}/role/toDistributeRole.action?id=<s:property value="id" />' target="mainFrame">
													<font color="blue">分配</font>
												</a>
											</span>
										</td>
									</tr>
								</s:iterator>
							</s:else>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		&nbsp;
		</div>
		</div>
		</div>
	</body>
</html>
